using System.Linq;
using NuGet.Enterprise.Server.Models;

namespace NuGet.Enterprise.Server.DataServices
{
    public class PackagesSource
    {
        private IServerPackageRepository _repository;

        public PackagesSource(IServerPackageRepository repository)
        {
            _repository = repository;
        }

        public IQueryable<PackagesEntity> Packages
        {
            get 
            {
                return from package in _repository.GetPackages().OfType<IServerPackage>()
                       select (new PackagesEntity(package));
            }
        }
    }
}
